class JiaJu(object):
    def __init__(self,name,area):
        self.name = name
        self.area = area
    def __str__(self):
        return f'这个家具的名称为{self.name},占地面积为{self.area}'

class Home(object):
    def __init__(self, area):
        self.area = area
        self.list = []
        self.residue = area
    def __str__(self):
        return f'房间的总面积为{self.area},含有家具{self.list},剩余面积为{self.residue}'
    def add(self,item):
        """添加家具"""
        if self.residue < item.area:
            print('家具太大，装不下！')
        else:
            self.residue -= item.area
            self.list.append(item.name)


home = Home(100)
print(home)

j1 = JiaJu('椅子', 20)
home.add(j1)
print(home)

j2 = JiaJu('桌子',50)
home.add(j2)
print(home)

j3 = JiaJu('沙发',40)
home.add(j3)
print(home)
